# Group Access Codes
Access Codes related to the events.

| Parameter | Description | Type | Required |
|:----------|-------------|------|----------|
| `code`  | Access Code | string | yes |
| `access-url` | URL of the access code | string | - |
| `is-active` | If the access code is active | boolean | - |
| `tickets-number` | Tickets Number for Access Code | integer (>=0) | - |
| `min-quantity` | Minimum number of tickets for Access Code | integer (>=0) | - |
| `max-quantity` | Maximum number of tickets for Access Code | integer (>=0) | - |
| `valid-from` | Access Code valid from | ISO 8601 (tz-aware) | - |
| `valid-till` | Access Code valid till | ISO 8601 (tz-aware) | - |
| `created-at` | Access Code created at | ISO 8601 (tz-aware) | - |



## Access Code Collection [/v1/access-codes{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
    + sort (optional, string, `code`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.

### Create Access Code [POST]
Create a new Access Code with `event_id` and `user_id`.

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body

            {
              "data": {
              "type": "access-code",
              "relationships":{
                     "event":{
                       "data":{
                         "type":"event",
                         "id":"1"
                       }
                     },
                     "marketer":{
                       "data":{
                         "type":"user",
                         "id":"1"
                       }
                     }
                    },
              "attributes": {
                      "code": "AC101",
                      "access-url": "https://my-access-code-url.com",
                      "is-active": "false",
                      "tickets-number": "404",
                      "min-quantity": "0",
                      "max-quantity": "100",
                      "valid-from": "2017-06-18T18:30:00+00:00",
                      "valid-till": "2017-06-24T18:30:00+00:00"
                  }
                }
            }

+ Response 201 (application/vnd.api+json)

        {
            "data": {
                "relationships": {
                    "tickets": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/tickets",
                            "related": "/v1/access-codes/1/tickets"
                        }
                    },
                    "marketer": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/marketer",
                            "related": "/v1/access-codes/1/marketer"
                        }
                    },
                    "event": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/event",
                            "related": "/v1/access-codes/1/event"
                        }
                    }
                },
                "attributes": {
                    "code": "AC101",
                    "valid-from": "2017-06-18T18:30:00+00:00",
                    "access-url": "https://my-access-code-url.com",
                    "min-quantity": 0,
                    "tickets-number": 404,
                    "max-quantity": 100,
                    "deleted-at": null,
                    "is-active": false,
                    "valid-till": "2017-06-24T18:30:00+00:00"
                },
                "type": "access-code",
                "id": 1,
                "links": {
                    "self": "/v1/access-codes/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/access-codes/1"
            }
        }


## Access Code Detail [/v1/access-codes/{access_code_id}]
+ Parameters
    + access_code_id: 1 (integer) - ID of the access code in the form of an integer

### Access Code Detail [GET]
Get a single access code.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "data": {
                "relationships": {
                    "tickets": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/tickets",
                            "related": "/v1/access-codes/1/tickets"
                        }
                    },
                    "marketer": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/marketer",
                            "related": "/v1/access-codes/1/marketer"
                        }
                    },
                    "event": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/event",
                            "related": "/v1/access-codes/1/event"
                        }
                    }
                },
                "attributes": {
                    "code": "AC101",
                    "valid-from": "2017-06-18T18:30:00+00:00",
                    "access-url": "https://my-access-code-url.com",
                    "min-quantity": 0,
                    "tickets-number": 404,
                    "max-quantity": 100,
                    "is-active": false,
                    "deleted-at": null,
                    "valid-till": "2017-06-24T18:30:00+00:00"
                },
                "type": "access-code",
                "id": 1,
                "links": {
                    "self": "/v1/access-codes/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/access-codes/1"
            }
        }


### Update Access Code [PATCH]
Update a single access code with `id`.

+ `id` (integer) - ID of the record to update **(required)**

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body

            {
              "data": {
              "attributes": {
                      "code": "AC101",
                      "access-url": "https://my-access-code-url.com",
                      "is-active": "true",
                      "tickets-number": "404",
                      "min-quantity": "0",
                      "max-quantity": "100",
                      "valid-from": "2017-06-18T18:30:00+00:00",
                      "valid-till": "2017-06-24T18:30:00+00:00"
                  },
              "type": "access-code",
              "id": "1"
              }
            }


+ Response 200 (application/vnd.api+json)

        {
            "data": {
                "relationships": {
                    "tickets": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/tickets",
                            "related": "/v1/access-codes/1/tickets"
                        }
                    },
                    "marketer": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/marketer",
                            "related": "/v1/access-codes/1/marketer"
                        }
                    },
                    "event": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/event",
                            "related": "/v1/access-codes/1/event"
                        }
                    }
                },
                "attributes": {
                    "code": "AC101",
                    "valid-from": "2017-06-18T18:30:00+00:00",
                    "access-url": "https://my-access-code-url.com",
                    "min-quantity": 0,
                    "tickets-number": 404,
                    "max-quantity": 100,
                    "is-active": true,
                    "deleted-at": null,
                    "valid-till": "2017-06-24T18:30:00+00:00"
                },
                "type": "access-code",
                "id": 1,
                "links": {
                    "self": "/v1/access-codes/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/access-codes/1"
            }
        }

### Delete Access Code [DELETE]
Delete a single Access code.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
          "meta": {
            "message": "Object successfully deleted"
          },
          "jsonapi": {
            "version": "1.0"
          }
        }

## Access Code Detail using the Code [/v1/events/{event_id}/access-codes/{code}]
+ Parameters
    + code: AC101 (string) - code of the access-code.
    + event_id: 1 (integer) - ID of the Event in the form of an integer.

### Access Code Detail [GET]
Get a single access code using the code.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "data": {
                "relationships": {
                    "tickets": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/tickets",
                            "related": "/v1/access-codes/1/tickets"
                        }
                    },
                    "marketer": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/marketer",
                            "related": "/v1/access-codes/1/marketer"
                        }
                    },
                    "event": {
                        "links": {
                            "self": "/v1/access-codes/1/relationships/event",
                            "related": "/v1/access-codes/1/event"
                        }
                    }
                },
                "attributes": {
                    "code": "AC101",
                    "valid-from": "2017-06-18T18:30:00+00:00",
                    "access-url": "https://my-access-code-url.com",
                    "min-quantity": 0,
                    "tickets-number": 404,
                    "max-quantity": 100,
                    "is-active": false,
                    "deleted-at": null,
                    "valid-till": "2017-06-24T18:30:00+00:00"
                },
                "type": "access-code",
                "id": 1,
                "links": {
                    "self": "/v1/access-codes/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/access-codes/1"
            }
        }


## Get Access Codes for an Event [/v1/events/{event_identifier}/access-codes{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + event_identifier: 1 (string) - identifier or event id of the event. (b8324ae2 is an example of identifier)
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
    + sort (optional, string, `code`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.

### List All Access Codes of an Event [GET]
Get a list of Access Codes.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)


        {
            "meta": {
                "count": 1
            },
            "data": [
                {
                    "relationships": {
                        "tickets": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/tickets",
                                "related": "/v1/access-codes/1/tickets"
                            }
                        },
                        "marketer": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/marketer",
                                "related": "/v1/access-codes/1/marketer"
                            }
                        },
                        "event": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/event",
                                "related": "/v1/access-codes/1/event"
                            }
                        }
                    },
                    "attributes": {
                        "code": "AC101",
                        "valid-from": "2017-06-18T18:30:00+00:00",
                        "access-url": "https://my-access-code-url.com",
                        "min-quantity": 0,
                        "tickets-number": 404,
                        "max-quantity": 100,
                        "is-active": true,
                        "deleted-at": null,
                        "valid-till": "2017-06-24T18:30:00+00:00"
                    },
                    "type": "access-code",
                    "id": 1,
                    "links": {
                        "self": "/v1/access-codes/1"
                    }
                }
            ],
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/events/1/access-codes"
            }
        }


## Get Access Codes for a User [/v1/users/{user_id}/access-codes{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + user_id: 1 (integer) - ID of the specific user in integer
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
    + sort (optional, string, `code`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.

### List All Access Codes for a User [GET]
Get a list of Access Codes.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)



        {
            "meta": {
                "count": 1
            },
            "data": [
                {
                    "relationships": {
                        "tickets": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/tickets",
                                "related": "/v1/access-codes/1/tickets"
                            }
                        },
                        "marketer": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/marketer",
                                "related": "/v1/access-codes/1/marketer"
                            }
                        },
                        "event": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/event",
                                "related": "/v1/access-codes/1/event"
                            }
                        }
                    },
                    "attributes": {
                        "code": "AC101",
                        "valid-from": "2017-06-18T18:30:00+00:00",
                        "access-url": "https://my-access-code-url.com",
                        "min-quantity": 0,
                        "tickets-number": 404,
                        "max-quantity": 100,
                        "is-active": true,
                        "deleted-at": null,
                        "valid-till": "2017-06-24T18:30:00+00:00"
                    },
                    "type": "access-code",
                    "id": 1,
                    "links": {
                        "self": "/v1/access-codes/1"
                    }
                }
            ],
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/users/2/access-codes"
            }
        }


## Get Access Codes for a Ticket [/v1/tickets/{ticket_id}/access-codes{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + ticket_id: 1 (integer) - ID of the ticket in the form of an integer
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
    + sort (optional, string, `code`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.

### List All Access Codes for a Ticket [GET]
Get a list of Access Codes.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)


        {
            "meta": {
                "count": 1
            },
            "data": [
                {
                    "relationships": {
                        "tickets": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/tickets",
                                "related": "/v1/access-codes/1/tickets"
                            }
                        },
                        "marketer": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/marketer",
                                "related": "/v1/access-codes/1/marketer"
                            }
                        },
                        "event": {
                            "links": {
                                "self": "/v1/access-codes/1/relationships/event",
                                "related": "/v1/access-codes/1/event"
                            }
                        }
                    },
                    "attributes": {
                        "code": "AC101",
                        "valid-from": "2017-06-18T18:30:00+00:00",
                        "access-url": "https://my-access-code-url.com",
                        "min-quantity": 0,
                        "tickets-number": 404,
                        "max-quantity": 100,
                        "is-active": true,
                        "deleted-at": null,
                        "valid-till": "2017-06-24T18:30:00+00:00"
                    },
                    "type": "access-code",
                    "id": 1,
                    "links": {
                        "self": "/v1/access-codes/1"
                    }
                }
            ],
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/tickets/1/access-codes"
            }
        }
